package com.pisolution.scheduler.runtime.master.scheduler;

import com.pisolution.scheduler.core.utils.JsonUtils;
import com.pisolution.scheduler.remote.command.Command;
import com.pisolution.scheduler.remote.command.CommandConverter;
import com.pisolution.scheduler.remote.command.CommandType;

/**
 * 用于管理节点告知工作节点取消给定任务的执行.
 *
 * @author sora
 * @version 0.1.0
 */
public final class TaskKillRequestCommand implements CommandConverter {
    private static final long serialVersionUID = -708587590164715038L;

    // -------------------------------------------------------------------------------------------------

    /** 需要取消执行的任务节点标识. */
    private int taskId;

    // -------------------------------------------------------------------------------------------------
    //  属性访问
    // -------------------------------------------------------------------------------------------------

    public int getTaskId() {
        return this.taskId;
    }

    public void setTaskId(int taskId) {
        this.taskId = taskId;
    }

    // -------------------------------------------------------------------------------------------------
    //  指令转换
    // -------------------------------------------------------------------------------------------------

    @Override
    public Command convert() {
        final Command command = new Command();

        command.setType(CommandType.TASK_KILL_REQUEST);
        command.setBody(JsonUtils.serialize(this));

        return command;
    }
}
